import * as types from '../constants/userTypes'

const initialState = {
  user: {},
  errMsg: ''
}

export default function user (state = initialState, action) {
  switch (action.type) {
    case types.UPDATE_USERINFO:
      return {
        ...state,
        user: { ...state.user, ...action.user }
      }
      break
    case types.IS_ERROR:
      return {
        ...state,
        errMsg: action.err
      }
      break
    default:
      return state
  }
}
